


<ul class="porder-list">

    <volist name="list" id="list">
    <li>
        <div class="li-head clearfix">
            <span class="state c-orange fl">
                <if condition="$list.order_status eq -1">已取消</if>
                <if condition="$list.order_status eq 0">待付款</if>
                <if condition="$list.order_status eq 1">已预约</if>
                <if condition="$list.order_status eq 2">已完成</if>
            </span>
            <span class="price fr">合计：￥{$list.goods_price}</span>
        </div>
        <div class="li-cont clearfix">
            <h3 class="t">{$config.index_company_name}【订单编号：{$list.order_sn}】</h3>
            <div class="c">
                <p>打球时间：{:date('Y-m-d H:i',$list.subscribe_time)}-{$list.end_time}</p>
                <p>联系电话：{$list.phone}</p>
                <p>备注：{$list.user_note}</p>
            </div>
        </div>
        <div class="li-btm clearfix">
            <if condition="$list.order_status eq 2"><a href="{:U('Index/index')}" class="btn">再次预定</a></if>
            <if condition="$list.order_status eq 1"><a href="javascript:;" class="btn"  data-url="{:U('Payment/cancel_order')}" data-id="{$list.order_sn}" onclick="cancel_fun(this)">取消订单</a></if>
            <if condition="$list.order_status eq 0"><a href="{:U('Payment/pay_order',array('itemid' => $list.order_sn))}" class="btn">立即付款</a></if>
            <a href="tel:{$config.index_phone}" class="btn">联系客服</a>
            <if condition="$list.order_status neq 1">
                <a href="javascript:;" class="btn" data-url="{:U('Order/del_order')}" data-id="{$list.order_sn}" onclick="del_fun(this)">删除订单</a>
            </if>
        </div>
    </li>
    </volist>
</ul>

<script>
    function del_fun(obj){
        layer.confirm('确认删除？', function () {
            $.ajax({
                type: 'post',
                url: $(obj).attr('data-url'),
                data: {id: $(obj).attr('data-id')},
                dataType: 'json',
                success: function (result) {
                    if (result.status == 200) {
                        layer.msg(result.msg,{icon:1,time:2000},function(){if(result.url){ window.location.href = result.url;}});
                    } else {
                        layer.msg(result.msg,{icon:2,time:2000},function(){if(result.url){ window.location.href = result.url;}});
                    }
                }
            })
        });
    }

    function cancel_fun(obj){
        layer.confirm('确认取消订单？', function () {
            $.ajax({
                type: 'post',
                url: $(obj).attr('data-url'),
                data: {id: $(obj).attr('data-id')},
                dataType: 'json',
                success: function (result) {
                    if (result.status == 200) {
                        layer.msg(result.msg,{icon:1,time:2000},function(){if(result.url){ window.location.href = result.url;}});
                    } else {
                        layer.msg(result.msg,{icon:2,time:2000},function(){if(result.url){ window.location.href = result.url;}});
                    }
                }
            })
        });
    }
</script>